<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*后代选择器*/
        .done li {
            color: green;
            text-decoration: line-through;
        }

        .todo li {
            width: 200px;
            height: 35px;
            position: relative;
        }

        /*.todo li button{
             float: right;
         }*/
        .todo li button {
            /*绝对定位：会以第一个不是默认定位得父元素为原点进行定位*/
            position: absolute;
            top: 0;
            right: 0;
        }
    </style>
</head>

<body>
    <p>待办事项</p>
    <!--第一部分，记录-->
    <input type="text" id="inp" placeholder="请输入待办事项">
    <button onclick="save()">保存</button>
    <!--第二部分，待办事项-->
    <p>待办事项</p>
    <ol class="todo" id="todo">
    </ol>
    <!--第三部分，已完成事项-->
    <p>已完成事项</p>
    <ol class="done">
        <li>21</li>
    </ol>
    <script>
        //存放事件
        let evenlist = [];
        function save() {
            //保存事件，添加到数组中
            let event = inp.value;
            evenlist.push(event);
            console.log(evenlist);
            let content = '';
            for (let index = 0; index < evenlist.length; index++) {
                content += `<li>${evenlist[index]}</li>`
            }
            todo.innerHTML = content;
        }
    </script>
</body>

</html>